#ifndef RobotServerCmd_H
#define RobotServerCmd_H

#include "RobotServer.h"
#include "RobotCmdNode.hpp"
#include <mutex>

class QSharedMemory;

class RobotServerCmd : public RobotServer
{
    Q_OBJECT
public:
    explicit RobotServerCmd(quint16 usPort, int argc, char** argv, QObject *parent = nullptr);
    ~RobotServerCmd();

    void call_processTcp(unsigned int dwSize);

    void call_onGenRReady(const QByteArray& baData);

protected:
    virtual int parse(unsigned char *buf, qint64 len);
    void processJson(const QVariantMap& json);

private slots:
    void processTcp(unsigned int dwSize);
    void onGenRReady(const QByteArray& baData);


private:
    void rosSpinThread();
    std::shared_ptr<RobotCmdNode> m_robotCmdNode;
    int argc_;
    char** argv_;
    std::thread m_ros_spin_thread;

private:
    QSharedMemory* m_smTcp;
    std::mutex m_mutexVar;
};

#endif // RobotServerCmd_H
